# -*- coding:utf8 -*-

from PyQt4.QtCore import *
from PyQt4.QtGui import *
from tableHuman import tableHuman
import sys
sys.path.append('adn/')
from Main import * 
from Score import *

class AddWind(QWidget):
	def __init__(self, parent=None):
		QWidget.__init__(self, parent)             
		#self.application = application 
		#self.humain = application.getHuman()
		#self.mainScene = application.scene3d
		self.main = Main(Score())
		self.equiv = {}
		self.adn = self.main.getADN()
		self.noms = self.adn.getGenesName()
		self.listeCombo = {}
		j = 0
		self.inter = {}		

		#print self.noms
		for n in self.noms:

			self.listeCombo[n] = QComboBox()
			tab = {}
			i = 0

			self.gene = self.adn.getGeneByName(n)
			#print self.gene.getAllelesName()
			for all in self.gene.getAllelesName():
				tab[i] = self.gene.getAlleleByName(all).getValeur()
				self.listeCombo[n].addItem(all)
				if n != "ethnics" :
					self.inter[all] = tab[i][0]
				i += 1


			self.equiv[n] = self.inter
			inter = {}
			#print tab[i][0]
			#self.listeCombo[j]=(tab)
			#self.equiv.append(tab[i])
			j += 1
			#print self.listeCombo

		print self.equiv
		'''
		self.adn = self.main.getADN()
		self.noms = self.adn.getGeneByName().keys()
		self.listCombo = {}
		for n in self.noms:
		self.listCombo[n] = QComboBox()
		gene = self.adn.getGene(n)
		for all in gene.getAlleles().keys():
			self.listCombo[n].addItem(gene.getAllele(all).getName())


		self.taille = len(self.liste) +1
		self.listCombo[taille] = QComboBox()
		self.listCombo[taille].addItem(0)
		self.listCombo[taille].addItem(0.5)
		self.listCombo[taille].addItem(1)
		'''


		layout_principale = QVBoxLayout()            #Fenetre principale
		layout_menu = QHBoxLayout()                  #Liste menu bouton (ouvrir, sauvegarde, quitter)                  
		layout_affichage = QHBoxLayout()             #Layout principal d'affichage
		layout_gen = QVBoxLayout()                   #Layout de la liste des genes
		  

		#Declaration des boutons du menu
		self.ouvrir = QPushButton("Ouvrir")
		self.sauvegarder = QPushButton("Sauvegarder")
		self.quitter= QPushButton("Quitter")
		self.modeliser = QPushButton("Modeliser")


		layout_menu.addWidget(self.ouvrir)
		layout_menu.addWidget(self.sauvegarder)
		layout_menu.addWidget(self.quitter)    
		layout_menu.addWidget(self.modeliser)


		#Bouton de modélisation
		self.modelisation = QPushButton("Modeliser")
		self.test = QPushButton("Test")


		#print self.listeCombo

		for widg in self.listeCombo.keys():
			layout_gen.addWidget(self.listeCombo[widg])

		#layout_allele_age.addWidget(self.listeCombo[taille])
		layout_affichage.addLayout(layout_gen)

		layout_principale.addLayout(layout_menu)
		layout_principale.addLayout(layout_affichage)

		self.setLayout(layout_principale)

		#self.quitter.connect(self.quitter,SIGNAL("clicked(bool)"), SLOT("quit()"))
		#self.modeliser.connect(self.modeliser,SIGNAL("clicked(bool)"), self.modelisation)
		self.quitter.connect(self.quitter, SIGNAL("clicked(bool)"), self.quitter)

	
	def modelisation(self):
		for all in listeCombo :
			index = all.currentIndex()
			print index 

	def quitter(self):
		print "pourquoi sa marche pas ?"
